<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="/estilos/instrutorprincipal.css" style="text/css" rel="stylesheet">
</head>

<body>
<form method="post" action="#">
	<label>Selecione para visualizar as requisi&ccedil;&otilde;es: </label><select name="material" onchange="submit()">
		<option>Escolha o material:</option>
			<?php
				include_once '../gerenciadores/AutoloadGerenciadores.php';
				include_once 'function/erros.php';
				exibeErros();
				
				__autoload("GerenciadorDaSmap");
				
				$gerSmap = new GerenciadorDaSmap();
				$tabMateriais = $gerSmap->exibeTabelaMateriais();
				
				foreach ($tabMateriais as $material){
					echo "<option value='".$material->getIdMaterial()."'>".$material->getDescricao()."</option>";
				}
			?>
	</select>
</form>
<table>
	<tr>
		<th>Data de Aula</th><th>Material</th><th>Qtd</th><th>Instrutor</th>
	</tr>
	<?php
		if(isset($_POST['material'])){
			$id = $_POST['material'];
			
			
			
			foreach ($tabMateriais as $materiais){
				if($materiais->getIdMaterial()==$id){
					$materialRequisicao = $materiais;
				}
			}
			
			$tabRequisicao = $gerSmap->exibeRequisicaoPorMaterial($materialRequisicao);
				foreach ($tabRequisicao as $requisicao){
					echo "<tr>
					<td>".$requisicao->getDataAula()."</td>
					<td>".$requisicao->getMaterial()->getDescricao()."</td>
					<td>".$requisicao->getMaterial()->getQuantidade()."</td>
					<td>".$requisicao->getInstrutor()."</td>
					</tr>";
				}
		}
		
	 ?>
</table>
</body>
</html>